package com.dz.action;

import com.dz.bean.UserInfoBean;

import com.dz.bean.student;
import com.dz.service.IuserInfoLogin;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;



@Controller
public class userLogin {
    @Resource
    private IuserInfoLogin IuserInfoLogin;

    @RequestMapping("/login0")
    public ModelAndView login1(student userB){
        System.out.println("账号："+userB.getUsername()+"密码："+userB.getUserpsw());

        ModelAndView mav =new ModelAndView();
        boolean isOk =IuserInfoLogin.isLogin(userB);
        if (isOk==true)
        {
            mav.setViewName("login");
            mav.addObject("userName",userB.getUsername());
            System.out.println("登录成功");

        }
        else {
            mav.setViewName("../../index");
        }
        return mav;
    }


    @RequestMapping("/login00")
    public String login0(UserInfoBean userB, HttpServletRequest request){
        System.out.println("账号："+userB.getUsername()+"密码："+userB.getPsw());
        request.getSession().setAttribute("userName",userB.getUsername());

        return "login";
    }

}
